﻿#region Using

using System;
using System.Xml.Serialization;

using Menu.Components;

#endregion

namespace Menu.XmlEntities
{
    [Serializable]
    public abstract class XmlBaseEntity
    {
        public XmlBaseEntity()
        {
            this.Layer = 1;
        }

        [XmlAttribute("Id")]
        public string Id { get; set; }

        [XmlAttribute("Layer")]
        public int Layer { get; set; }

        [XmlAttribute("Opacity")]
        public int Opacity { get; set; }

        [XmlAttribute("Command")]
        public string Command { get; set; }

        internal virtual MenuComponentBase GetComponent(MenuComponentBase parent)
        {
            var comp = new MenuComponentBase(this.Id);
            comp.Opacity = this.Opacity / 100f;
            comp.Command = this.Command;
            comp.Parent = parent;
            comp.Layer = this.Layer;

            return comp;
        }
    }
}